using FireStarterModeller.BO;
using Habanero.Testability;

namespace FireStarterModeller.Test
{
    public class TestUtilsDMSortProperty
    {
        public static BOTestFactory<DMSortProperty> GetBuilder()
        {
            return BOTestFactoryRegistry.Instance.Resolve<DMSortProperty>();
        }

        /// <summary>
        /// Creates a new saved DMLookupList with a random value assigned to every property
        /// </summary>
        public static DMSortProperty CreateSavedDMSortProperty()
        {
            DMSortProperty dMLookupList = CreateUnsavedValidDMSortProperty();
            dMLookupList.Save();
            return dMLookupList;
        }

        /// <summary>
        /// Creates a new unsaved DMLookupList with a random value assigned to every property
        /// </summary>
        public static DMSortProperty CreateUnsavedValidDMSortProperty()
        {
            return GetBuilder()
                .WithValueFor(prop => prop.SortDirection)
                .CreateValidBusinessObject();
        }
        /// <summary>
        /// Creates a new unsaved DMLookupList with a random value assigned to every property
        /// </summary>
        public static DMSortProperty CreateStandardDMSortProperty()
        {
            return GetBuilder()
                .WithValue(prop => prop.DMSortOrder, TestUtilsDMSortOrder.CreateStandardDMSortOrder())
                .WithValue(prop => prop.PropertyName, "SortPropName")
                .WithValue(prop => prop.SortDirection, "Descending")
                .WithValue(prop => prop.SortPosition, 4)
                .CreateValidBusinessObject();
        }

        /// <summary>
        /// Creates a new unsaved DMLookupList where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static DMSortProperty CreateUnsavedDefaultDMSortProperty()
        {
            DMSortProperty dMLookupList = new DMSortProperty();
            return dMLookupList;
        }



        /// <summary>
        /// Creates a new unsaved DMSortProperty with a random value assigned to every property
        /// </summary>
        public static DMSortProperty CreateUnsavedValidDMSortProperty(DMSortOrder dmSortOrder)
        {
            DMSortProperty dMSortProperty = new DMSortProperty();
            dMSortProperty.DMSortOrder = dmSortOrder;
            dMSortProperty.PropertyName = TestUtilsShared.GetRandomString();
            dMSortProperty.SortDirection = "DESC";
            dMSortProperty.SortPosition = TestUtilsShared.GetRandomInt();
            return dMSortProperty;
        }

        /// <summary>
        /// Creates a new unsaved DMSortProperty with a random value assigned to every property
        /// </summary>
        public static DMSortProperty CreateUnsavedValidDMSortProperty(DMSortOrder dMSortOrder, int position)
        {
            DMSortProperty dmSortProperty3 = CreateUnsavedValidDMSortProperty(dMSortOrder);
            dmSortProperty3.SortPosition = position;
            return dmSortProperty3;
        }
    }
}